using Circus.CodeEditor;

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
namespace Circus.Syntax.CodeCompletion
{
	public class ListMembers : CodeCompletionProvider, ICodeCompletionProvider, IList<IComparable>, ICollection<IComparable>, IEnumerable<IComparable>, IEnumerable
	{
		private bool showHints = true;
		private bool showQualifiers = true;
		private bool showResults = true;
		private bool showParams = false;
		public override int ColumnCount
		{
			get
			{
				return 5;
			}
		}
		public new virtual ListMember this[int index]
		{
			get
			{
				return (ListMember)base[index];
			}
			set
			{
				base[index] = value;
			}
		}
		public virtual bool ShowQualifiers
		{
			get
			{
				return this.showQualifiers;
			}
			set
			{
				if (this.showQualifiers != value)
				{
					this.showQualifiers = value;
					this.OnShowQualifiersChanged();
				}
			}
		}
		public virtual bool ShowResults
		{
			get
			{
				return this.showResults;
			}
			set
			{
				if (this.showResults != value)
				{
					this.showResults = value;
					this.OnShowResultsChanged();
				}
			}
		}
		public virtual bool ShowParams
		{
			get
			{
				return this.showParams;
			}
			set
			{
				if (this.showParams != value)
				{
					this.showParams = value;
					this.OnShowParamsChanged();
				}
			}
		}
		public virtual bool ShowHints
		{
			get
			{
				return this.showHints;
			}
			set
			{
				if (this.showHints != value)
				{
					this.showHints = value;
					this.OnShowHintsChanged();
				}
			}
		}
	
		protected virtual void OnShowQualifiersChanged()
		{
		}
		protected virtual void OnShowResultsChanged()
		{
		}
		protected virtual void OnShowParamsChanged()
		{
		}
		protected virtual void OnShowHintsChanged()
		{
		}
		public ListMembers()
		{
			this.UseHtmlFormatting = true;
		}
		public override int GetImageIndex(int index)
		{
			return this[index].ImageIndex;
		}
		public override string GetDescription(int index)
		{
			string result;
			if (this.showHints)
			{
				result = this[index].Description;
			}
			else
			{
				result = string.Empty;
			}
			return result;
		}
		public override string GetName(int index)
		{
			return this[index].Name;
		}
		public override string GetDisplayText(int index)
		{
			return string.IsNullOrEmpty(this[index].DisplayText) ? this[index].Name : this[index].DisplayText;
		}
		public override int GetPriority(int index)
		{
			return this[index].Priority;
		}
		public override string GetText(int index)
		{
			return this[index].Name;
		}
		public override string GetColumnText(int index, int column)
		{
			string result;
			switch (column)
			{
			case 0:
				result = this[index].Qualifier;
				break;
			case 1:
				result = this[index].DataType;
				break;
			case 2:
				result = this[index].Name;
				break;
			case 3:
				result = this[index].DisplayText;
				break;
			case 4:
				result = this[index].ParamText;
				break;
			case 5:
				result = this[index].Description;
				break;
			default:
				result = string.Empty;
				break;
			}
			return result;
		}
		public override bool ColumnVisible(int column)
		{
			bool result;
			switch (column)
			{
			case 0:
				result = this.showQualifiers;
				break;
			case 1:
				result = this.showResults;
				break;
			case 2:
				result = true;
				break;
			case 3:
				result = false;
				break;
			case 4:
				result = this.showParams;
				break;
			default:
				result = false;
				break;
			}
			return result;
		}
		public override bool ColumnSpace(int column)
		{
			return true;
		}
		public virtual ListMember CreateListMember()
		{
			return new ListMember(this);
		}
		public virtual ListMember AddListMember()
		{
			ListMember listMember = this.CreateListMember();
			base.Add(listMember);
			return listMember;
		}
		public void AddListMember(ListMember member)
		{
			base.Add(member);
		}
		public virtual ListMember InsertListMember(int index)
		{
			ListMember listMember = this.CreateListMember();
			base.Insert(index, listMember);
			return listMember;
		}
		public virtual void ResetShowQualifiers()
		{
			this.ShowQualifiers = true;
		}
		public virtual void ResetShowResults()
		{
			this.ShowResults = true;
		}
		public virtual void ResetShowParams()
		{
			this.ShowParams = false;
		}
		public virtual void ResetShowHints()
		{
			this.ShowHints = true;
		}
	}
}
